<template>
  <main>
    <PdfViewer />
    <ReadingCountdown />
    <el-alert
      style="position: fixed; top: 0; z-index: 2"
      :title="`答题即将在 ${START_ANSWER_TIME} 开始`"
      type="success"
      :closable="false"
    >
    </el-alert>
  </main>
</template>

<script>
import { mapMutations, mapState } from 'vuex';
import PdfViewer from '@/components/PdfViewer';
import ReadingCountdown from '@/components/ReadingCountdown';
import { GET_USER_INFO } from '@/store/mutation-types';

export default {
  components: { PdfViewer, ReadingCountdown },
  methods: {
    ...mapMutations({
      getUserInfo: GET_USER_INFO,
    }),
  },
  computed: {
    ...mapState(['START_ANSWER_TIME', 'token']),
  },
  mounted() {
    this.getUserInfo();
    this.$nextTick(() => {
      if (!this.token) this.$router.replace('/');
    });
  },
};
</script>

<style></style>
